package hk.ust.android_competition.data_reload_tools;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;

/**
 * Created by Silver on 3/1/15.
 */
public class HttpTextFileGetter {
    private String path;

    public HttpTextFileGetter(String path) {
        this.path = path;
    }

    public String get() throws IOException {
        // Create a URL for the desired page
        URL url = new URL(path);

        // Read all the text returned by the server
        BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
        String str;
        StringBuilder string_buf = new StringBuilder();
        while ((str = in.readLine()) != null) {
            string_buf.append(str);
        }
        in.close();
        return str;

    }
}
